Add --all-features flag to cargo
authorDaniel Albert <albert_daniel@t-online.de>
Wed, 31 Aug 2016 17:03:26 +0000 (19:03 +0200)
committerDaniel Albert <albert_daniel@t-online.de>
Wed, 31 Aug 2016 17:03:26 +0000 (19:03 +0200)
25 files changed:
src/bin/bench.rs
src/bin/build.rs
src/bin/doc.rs
src/bin/install.rs
src/bin/metadata.rs
src/bin/run.rs
src/bin/rustc.rs
src/bin/rustdoc.rs
src/bin/test.rs
src/cargo/core/package.rs
src/cargo/ops/cargo_compile.rs
src/cargo/ops/cargo_output_metadata.rs
src/cargo/ops/cargo_package.rs
src/etc/_cargo
src/etc/cargo.bashcomp.sh
src/etc/man/cargo-bench.1
src/etc/man/cargo-build.1
src/etc/man/cargo-doc.1
src/etc/man/cargo-install.1
src/etc/man/cargo-metadata.1
src/etc/man/cargo-run.1
src/etc/man/cargo-rustc.1
src/etc/man/cargo-rustdoc.1
src/etc/man/cargo-test.1
tests/features.rs

index c7cf6b69332f6af55d8a0da03f29cc33716ac246..f2d028d34e46adeb5eb5526458faa21a00a6a69d 100644 (file)
@@ -9,6 +9,7 @@ pub struct Options {
     flag_package: Vec<String>,
     flag_jobs: Option<u32>,
     flag_features: Vec<String>,
+    flag_all_features: bool,
     flag_no_default_features: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
@@ -42,6 +43,7 @@ Options:
     -p SPEC, --package SPEC ...  Package to run benchmarks for
     -j N, --jobs N               Number of parallel jobs, defaults to # of CPUs
     --features FEATURES          Space-separated list of features to also build
+    --all-features               Build all available features
     --no-default-features        Do not build the `default` feature
     --target TRIPLE              Build for the target triple
     --manifest-path PATH         Path to the manifest to build benchmarks for
@@ -83,6 +85,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
             jobs: options.flag_jobs,
             target: options.flag_target.as_ref().map(|s| &s[..]),
             features: &options.flag_features,
+            all_features: options.flag_all_features,
             no_default_features: options.flag_no_default_features,
             spec: &options.flag_package,
             exec_engine: None,
index 601344adf7c6ee4264e20c01fc68349e125815f5..2f23ce1be3bf99ec86d3cf6f23064590426700a0 100644 (file)
@@ -11,6 +11,7 @@ pub struct Options {
     flag_package: Vec<String>,
     flag_jobs: Option<u32>,
     flag_features: Vec<String>,
+    flag_all_features: bool,
     flag_no_default_features: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
@@ -44,6 +45,7 @@ Options:
     --bench NAME                 Build only the specified benchmark target
     --release                    Build artifacts in release mode, with optimizations
     --features FEATURES          Space-separated list of features to also build
+    --all-features               Build all available features
     --no-default-features        Do not build the `default` feature
     --target TRIPLE              Build for the target triple
     --manifest-path PATH         Path to the manifest to compile
@@ -79,6 +81,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         jobs: options.flag_jobs,
         target: options.flag_target.as_ref().map(|t| &t[..]),
         features: &options.flag_features,
+        all_features: options.flag_all_features,
         no_default_features: options.flag_no_default_features,
         spec: &options.flag_package,
         exec_engine: None,
index 7f4fc2878e574cf9c480908002faa6fbd3b55edb..c4139987cf753ca90df1f6b229e0911d28fdd911 100644 (file)
@@ -7,6 +7,7 @@ use cargo::util::important_paths::{find_root_manifest_for_wd};
 pub struct Options {
     flag_target: Option<String>,
     flag_features: Vec<String>,
+    flag_all_features: bool,
     flag_jobs: Option<u32>,
     flag_manifest_path: Option<String>,
     flag_no_default_features: bool,
@@ -39,6 +40,7 @@ Options:
     --bin NAME                   Document only the specified binary
     --release                    Build artifacts in release mode, with optimizations
     --features FEATURES          Space-separated list of features to also build
+    --all-features               Build all available features
     --no-default-features        Do not build the `default` feature
     --target TRIPLE              Build for the target triple
     --manifest-path PATH         Path to the manifest to document
@@ -74,6 +76,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
             jobs: options.flag_jobs,
             target: options.flag_target.as_ref().map(|t| &t[..]),
             features: &options.flag_features,
+            all_features: options.flag_all_features,
             no_default_features: options.flag_no_default_features,
             spec: &options.flag_package,
             exec_engine: None,
index 2a58688021dc7f52e4b4d10727aa52b35c5da4ef..544b115e9a22d483d4b98f08837a484b470b40a1 100644 (file)
@@ -6,6 +6,7 @@ use cargo::util::{CliResult, Config, ToUrl};
 pub struct Options {
     flag_jobs: Option<u32>,
     flag_features: Vec<String>,
+    flag_all_features: bool,
     flag_no_default_features: bool,
     flag_debug: bool,
     flag_bin: Vec<String>,
@@ -48,8 +49,9 @@ Specifying what crate to install:
 Build and install options:
     -h, --help                Print this message
     -j N, --jobs N            Number of parallel jobs, defaults to # of CPUs
-    --features FEATURES       Space-separated list of features to activate
     -f, --force               Force overwriting existing crates or binaries
+    --features FEATURES       Space-separated list of features to activate
+    --all-features            Build all available features
     --no-default-features     Do not build the `default` feature
     --debug                   Build in debug mode instead of release mode
     --bin NAME                Only install the binary NAME
@@ -104,6 +106,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         jobs: options.flag_jobs,
         target: None,
         features: &options.flag_features,
+        all_features: options.flag_all_features,
         no_default_features: options.flag_no_default_features,
         spec: &[],
         exec_engine: None,
index d5c2d09056ed7ac32d4b14ea01c92d4b965d51a5..4553711045b23590ba9aefe9ae10f718873d97cb 100644 (file)
@@ -7,6 +7,7 @@ use cargo::util::{CliResult, Config};
 pub struct Options {
     flag_color: Option<String>,
     flag_features: Vec<String>,
+    flag_all_features: bool,
     flag_format_version: u32,
     flag_manifest_path: Option<String>,
     flag_no_default_features: bool,
@@ -27,6 +28,7 @@ Usage:
 Options:
     -h, --help                 Print this message
     --features FEATURES        Space-separated list of features
+    --all-features             Build all available features
     --no-default-features      Do not include the `default` feature
     --no-deps                  Output information only about the root package
                                and don't fetch dependencies.
@@ -50,6 +52,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<ExportInfo
 
     let options = OutputMetadataOptions {
         features: options.flag_features,
+        all_features: options.flag_all_features,
         no_default_features: options.flag_no_default_features,
         no_deps: options.flag_no_deps,
         version: options.flag_format_version,
index b889087d6656329cdda5e94c88b7c88c8f0f84fe..5f9843c83ba601f7a0ad17b6f11c800859009a84 100644 (file)
@@ -9,6 +9,7 @@ pub struct Options {
     flag_example: Option<String>,
     flag_jobs: Option<u32>,
     flag_features: Vec<String>,
+    flag_all_features: bool,
     flag_no_default_features: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
@@ -34,6 +35,7 @@ Options:
     -j N, --jobs N          Number of parallel jobs, defaults to # of CPUs
     --release               Build artifacts in release mode, with optimizations
     --features FEATURES     Space-separated list of features to also build
+    --all-features          Build all available features
     --no-default-features   Do not build the `default` feature
     --target TRIPLE         Build for the target triple
     --manifest-path PATH    Path to the manifest to execute
@@ -75,6 +77,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         jobs: options.flag_jobs,
         target: options.flag_target.as_ref().map(|t| &t[..]),
         features: &options.flag_features,
+        all_features: options.flag_all_features,
         no_default_features: options.flag_no_default_features,
         spec: &[],
         exec_engine: None,
index 10fd9fc9130751df6bda25c875b344bfc3130526..e81c8d18f7a6ad0bf0b3da636e8c709f975d0167 100644 (file)
@@ -12,6 +12,7 @@ pub struct Options {
     flag_package: Option<String>,
     flag_jobs: Option<u32>,
     flag_features: Vec<String>,
+    flag_all_features: bool,
     flag_no_default_features: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
@@ -47,6 +48,7 @@ Options:
     --release                Build artifacts in release mode, with optimizations
     --profile PROFILE        Profile to build the selected target for
     --features FEATURES      Features to compile for the package
+    --all-features           Build all available features
     --no-default-features    Do not compile default features for the package
     --target TRIPLE          Target triple which compiles will be for
     --manifest-path PATH     Path to the manifest to fetch dependencies for
@@ -97,6 +99,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         jobs: options.flag_jobs,
         target: options.flag_target.as_ref().map(|t| &t[..]),
         features: &options.flag_features,
+        all_features: options.flag_all_features,
         no_default_features: options.flag_no_default_features,
         spec: &options.flag_package.map_or(Vec::new(), |s| vec![s]),
         exec_engine: None,
index 010b003c58dbbfc36808ee375f9aa0e8e0bfb8bd..15e4a91ca667d32795a402cb46cefc560611ad87 100644 (file)
@@ -8,6 +8,7 @@ pub struct Options {
     arg_opts: Vec<String>,
     flag_target: Option<String>,
     flag_features: Vec<String>,
+    flag_all_features: bool,
     flag_jobs: Option<u32>,
     flag_manifest_path: Option<String>,
     flag_no_default_features: bool,
@@ -44,6 +45,7 @@ Options:
     --bench NAME             Build only the specified benchmark target
     --release                Build artifacts in release mode, with optimizations
     --features FEATURES      Space-separated list of features to also build
+    --all-features           Build all available features
     --no-default-features    Do not build the `default` feature
     --target TRIPLE          Build for the target triple
     --manifest-path PATH     Path to the manifest to document
@@ -83,6 +85,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
             jobs: options.flag_jobs,
             target: options.flag_target.as_ref().map(|t| &t[..]),
             features: &options.flag_features,
+            all_features: options.flag_all_features,
             no_default_features: options.flag_no_default_features,
             spec: &options.flag_package.map_or(Vec::new(), |s| vec![s]),
             exec_engine: None,
index cd823a59172b3a84ef9c3b1c5702ffe9e2d6e5f6..c5e687a648388fb5e390a2a45b3a9f1037fef5f2 100644 (file)
@@ -7,6 +7,7 @@ use cargo::util::important_paths::{find_root_manifest_for_wd};
 pub struct Options {
     arg_args: Vec<String>,
     flag_features: Vec<String>,
+    flag_all_features: bool,
     flag_jobs: Option<u32>,
     flag_manifest_path: Option<String>,
     flag_no_default_features: bool,
@@ -47,6 +48,7 @@ Options:
     -j N, --jobs N               Number of parallel jobs, defaults to # of CPUs
     --release                    Build artifacts in release mode, with optimizations
     --features FEATURES          Space-separated list of features to also build
+    --all-features               Build all available features
     --no-default-features        Do not build the `default` feature
     --target TRIPLE              Build for the target triple
     --manifest-path PATH         Path to the manifest to build tests for
@@ -115,6 +117,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
             jobs: options.flag_jobs,
             target: options.flag_target.as_ref().map(|s| &s[..]),
             features: &options.flag_features,
+            all_features: options.flag_all_features,
             no_default_features: options.flag_no_default_features,
             spec: &options.flag_package,
             exec_engine: None,
index ffd5c93640aa220e9b5e876cf11a0df8a5eabca2..c0554fbfc55a1dacea41cf09293194eca2c52bf0 100644 (file)
@@ -78,7 +78,7 @@ impl Package {
     pub fn package_id(&self) -> &PackageId { self.manifest.package_id() }
     pub fn root(&self) -> &Path { self.manifest_path.parent().unwrap() }
     pub fn summary(&self) -> &Summary { self.manifest.summary() }
-    pub fn targets(&self) -> &[Target] { self.manifest().targets() }
+    pub fn targets(&self) -> &[Target] { self.manifest.targets() }
     pub fn version(&self) -> &Version { self.package_id().version() }
     pub fn authors(&self) -> &Vec<String> { &self.manifest.metadata().authors }
     pub fn publish(&self) -> bool { self.manifest.publish() }
index 09643591b2a90d55e6b1810fb0bb174251660f16..25b96891787f3acab461981f3bb9d8ddca91223e 100644 (file)
@@ -44,6 +44,8 @@ pub struct CompileOptions<'a> {
     pub target: Option<&'a str>,
     /// Extra features to build for the root package
     pub features: &'a [String],
+    /// Flag whether all available features should be built for the root package
+    pub all_features: bool,
     /// Flag if the default feature should be built for the root package
     pub no_default_features: bool,
     /// Root package to build (if None it's the current one)
@@ -94,6 +96,7 @@ pub fn compile<'a>(ws: &Workspace<'a>, options: &CompileOptions<'a>)
 pub fn resolve_dependencies<'a>(ws: &Workspace<'a>,
                                 source: Option<Box<Source + 'a>>,
                                 features: Vec<String>,
+                                all_features: bool,
                                 no_default_features: bool)
                                 -> CargoResult<(PackageSet<'a>, Resolve)> {
 
@@ -115,10 +118,14 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>,
 
     try!(add_overrides(&mut registry, ws));
 
-    let method = Method::Required{
-        dev_deps: true, // TODO: remove this option?
-        features: &features,
-        uses_default_features: !no_default_features,
+    let method = if all_features {
+        Method::Everything
+    } else {
+        Method::Required {
+            dev_deps: true, // TODO: remove this option?
+            features: &features,
+            uses_default_features: !no_default_features,
+        }
     };
 
     let resolved_with_overrides =
@@ -137,7 +144,8 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>,
                       -> CargoResult<ops::Compilation<'a>> {
     let root_package = try!(ws.current());
     let CompileOptions { config, jobs, target, spec, features,
-                         no_default_features, release, mode,
+                         all_features, no_default_features,
+                         release, mode,
                          ref filter, ref exec_engine,
                          ref target_rustdoc_args,
                          ref target_rustc_args } = *options;
@@ -157,7 +165,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>,
     }
 
     let (packages, resolve_with_overrides) = {
-        try!(resolve_dependencies(ws, source, features, no_default_features))
+        try!(resolve_dependencies(ws, source, features, all_features, no_default_features))
     };
 
     let mut pkgids = Vec::new();
index 5178dbc8eec59c3a23c82d35d0e7c23b6e1dacb8..035c7350fe960046ceb0c75c377b83916440271b 100644 (file)
@@ -10,6 +10,7 @@ const VERSION: u32 = 1;
 pub struct OutputMetadataOptions {
     pub features: Vec<String>,
     pub no_default_features: bool,
+    pub all_features: bool,
     pub no_deps: bool,
     pub version: u32,
 }
@@ -45,6 +46,7 @@ fn metadata_full(ws: &Workspace,
     let deps = try!(ops::resolve_dependencies(ws,
                                               None,
                                               opt.features.clone(),
+                                              opt.all_features,
                                               opt.no_default_features));
     let (packages, resolve) = deps;
 
index e6a89e331b072b6d4a19876723b73789cbf4a2b1..3a6f51d5f130002396612af17b273ba1f5c39bdc 100644 (file)
@@ -275,6 +275,7 @@ fn run_verify(ws: &Workspace, tar: &File, opts: &PackageOpts) -> CargoResult<()>
         target: None,
         features: &[],
         no_default_features: false,
+        all_features: false,
         spec: &[],
         filter: ops::CompileFilter::Everything,
         exec_engine: None,
index 9a883dd25091d154a8105c8473f30808e647bd24..17585920252a7919d87a35e18e579460b3f9490a 100644 (file)
@@ -20,6 +20,7 @@ case $state in
             bench)
                 _arguments \
                     '--features=[space separated feature list]' \
+                    '--all-features[enable all available features]' \
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
                     "${command_scope_spec[@]}" \
@@ -36,6 +37,7 @@ case $state in
             build)
                 _arguments \
                     '--features=[space separated feature list]' \
+                    '--all-features[enable all available features]' \
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
                     "${command_scope_spec[@]}" \
@@ -64,6 +66,7 @@ case $state in
             doc)
                 _arguments \
                     '--features=[space separated feature list]' \
+                    '--all-features[enable all available features]' \
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
                     '--manifest-path=[path to manifest]: :_files -/' \
@@ -131,6 +134,7 @@ case $state in
                     '--debug[build in debug mode instead of release mode]' \
                     '--example[install the specified example instead of binaries]' \
                     '--features=[space separated feature list]' \
+                    '--all-features[enable all available features]' \
                     '--git=[URL from which to install the crate]' \
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
@@ -168,6 +172,7 @@ case $state in
                     '--no-default-features[do not include the default feature]' \
                     '--manifest-path=[path to manifest]: :_files -/' \
                     '--features=[space separated feature list]' \
+                    '--all-features[enable all available features]' \
                     '--format-version=[format version(default: 1)]' \
                     '--color=:colorization option:(auto always never)' \
                     ;;
@@ -241,6 +246,7 @@ case $state in
                 _arguments \
                     '--example=[name of the bin target]' \
                     '--features=[space separated feature list]' \
+                    '--all-features[enable all available features]' \
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
                     '--manifest-path=[path to manifest]: :_files -/' \
@@ -258,6 +264,7 @@ case $state in
                 _arguments \
                     '--color=:colorization option:(auto always never)' \
                     '--features=[features to compile for the package]' \
+                    '--all-features[enable all available features]' \
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
                     '--manifest-path=[path to the manifest to fetch dependencies for]' \
@@ -275,6 +282,7 @@ case $state in
                 _arguments \
                     '--color=:colorization option:(auto always never)' \
                     '--features=[space-separated list of features to also build]' \
+                    '--all-features[enable all available features]' \
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
                     '--manifest-path=[path to the manifest to document]' \
@@ -301,6 +309,7 @@ case $state in
             test)
                 _arguments \
                     '--features=[space separated feature list]' \
+                    '--all-features[enable all available features]' \
                     '(-h, --help)'{-h,--help}'[show help message]' \
                     '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
                     '--manifest-path=[path to manifest]: :_files -/' \
index b1652b6cc2acff127b2bc60b7c765bbcf9a71447..5c6675e90690266db58cdeda966b0de95c77ac4c 100644 (file)
@@ -17,7 +17,7 @@ _cargo()
        local opt_color='--color'
        local opt_common="$opt_help $opt_verbose $opt_quiet $opt_color"
        local opt_pkg='-p --package'
-       local opt_feat='--features --no-default-features'
+       local opt_feat='--features --all-features --no-default-features'
        local opt_mani='--manifest-path'
        local opt_jobs='-j --jobs'
 
index 7f32d196dcc1eed59e6274b30f86a60cb5e9a02d..dfb9ee4ec6185d31ec336405dfe2179907bec049 100644 (file)
@@ -83,6 +83,11 @@ Space\-separated list of features to also build.
 .RS
 .RE
 .TP
+.B \-\-all\-features
+Build all available features.
+.RS
+.RE
+.TP
 .B \-\-no\-default\-features
 Do not build the \f[C]default\f[] feature.
 .RS
index e4c00dc2110f8a6ab97816028df2d84d19a451b0..18c16c63da1e1b3895dc99e6dc74cd60d62242b4 100644 (file)
@@ -67,6 +67,11 @@ Build artifacts in release mode, with optimizations.
 .RS
 .RE
 .TP
+.B \-\-all\-features
+Build all available features.
+.RS
+.RE
+.TP
 .B \-\-features \f[I]FEATURES\f[]
 Space\-separated list of features to also build.
 .RS
index 54807f65486d307d61004a5e9a08143e26a9805e..f910957c6939cba21f190ca970160bb21245d269 100644 (file)
@@ -57,6 +57,11 @@ Space\-separated list of features to also build.
 .RS
 .RE
 .TP
+.B \-\-all\-features
+Build all available features.
+.RS
+.RE
+.TP
 .B \-\-no\-default\-features
 Do not build the \f[C]default\f[] feature.
 .RS
index 9944d9104d048b1abe4e65234092c3fcfac6daa2..8822e730f72482d130ca09d68126f3f54a6d3c96 100644 (file)
@@ -98,6 +98,11 @@ Space\-separated list of features to activate.
 .RS
 .RE
 .TP
+.B \-\-all\-features
+Build all available features.
+.RS
+.RE
+.TP
 .B \-f, \-\-force
 Force overwriting existing crates or binaries
 .RS
index 939d0265648e17ee4ea9ba7f35e08e0a6db14238..69d72535cb6849375c21314b574fb9df276bc896 100644 (file)
@@ -22,6 +22,11 @@ Space-separated list of features.
 .RS
 .RE
 .TP
+.B \-\-all\-features
+Build all available features.
+.RS
+.RE
+.TP
 .B \-\-no\-default\-features
 Do not include the \f[C]default\f[] feature.
 .RS
index 91d0bfba6c681a133ffc3173e728395750091f77..80473d2be460b68756ab1453837a3a23ef35dba9 100644 (file)
@@ -51,6 +51,11 @@ Space\-separated list of features to also build.
 .RS
 .RE
 .TP
+.B \-\-all\-features
+Build all available features.
+.RS
+.RE
+.TP
 .B \-\-no\-default\-features
 Do not build the \f[C]default\f[] feature.
 .RS
index b503fed1009099bc147024d296435d47331f76d0..f5d9a3521a471154cfa16dbd7939a96ca8e72286 100644 (file)
@@ -83,6 +83,11 @@ The version to yank or un\-yank.
 .RS
 .RE
 .TP
+.B \-\-all\-features
+Build all available features.
+.RS
+.RE
+.TP
 .B \-\-no\-default\-features
 Do not compile default features for the package.
 .RS
index 278e60886541f072199594b6cda6e2869e9fbb89..3a898a31a6bae42dca969d8a73407ec0100109f3 100644 (file)
@@ -81,6 +81,11 @@ Space-separated list of features to also build.
 .RS
 .RE
 .TP
+.B \-\-all\-features
+Build all available features.
+.RS
+.RE
+.TP
 .B \-\-no\-default\-features
 Do not build the \f[C]default\f[] feature.
 .RS
index 63f1b2b801d952a90d4f9f9562694300f6c16ce2..2d9907f0bd06ba775dd0bf8685595982411b67b7 100644 (file)
@@ -107,6 +107,11 @@ Space\-separated list of features to also build.
 .RS
 .RE
 .TP
+.B \-\-all\-features
+Build all available features.
+.RS
+.RE
+.TP
 .B \-\-no\-default\-features
 Do not build the \f[C]default\f[] feature.
 .RS
index 1551c703c22fab4d79486a17f340b6c861d5b5a7..a6921de381474b4202f170f464b7c8273415ac39 100644 (file)
@@ -960,4 +960,48 @@ fn dep_feature_in_cmd_line() {
                 execs().with_status(101).with_stderr("\
 [ERROR] feature names may not contain slashes: `bar/some-feat`
 "));
+
+#[test]
+fn all_features_flag_enables_all_features() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.0.1"
+            authors = []
+
+            [features]
+            foo = []
+            bar = []
+
+            [dependencies.baz]
+            path = "baz"
+            optional = true
+        "#)
+        .file("src/main.rs", r#"
+            #[cfg(feature = "foo")]
+            pub fn foo() {}
+
+            #[cfg(feature = "bar")]
+            pub fn bar() {
+                extern crate baz;
+                baz::baz();
+            }
+
+            fn main() {
+                foo();
+                bar();
+            }
+        "#)
+        .file("baz/Cargo.toml", r#"
+            [package]
+            name = "baz"
+            version = "0.0.1"
+            authors = []
+        "#)
+        .file("baz/src/lib.rs", "pub fn baz() {}");
+
+    assert_that(p.cargo_process("build").arg("--all-features"),
+                execs().with_status(0));
+}
 }